<template>
<view >
		<view  style="padding-bottom: 200rpx;">
			<view class="leaveNav">
				<view @click="attendanceTtileFun()" style="margin-left:-80rpx;font-weight: 800;">考勤状况
					<view class="leaveLine" v-show="isShowTitle"></view>
				</view>
				<view @click="attendanceTtileFun()"  style="margin-left:100rpx;font-weight: 800;" >违纪状况
					<view class="leaveLine" v-show="!isShowTitle"></view>
				</view>
			</view>
			<view class="leaveMgm"  v-for="(item,index) in attArr" :key="item.id">
				<view v-show="isShowTitle" >
					
						<view style="display: flex;flex-direction: row;">
							<view class="leaveCheck" value="yes" @click="checkFun(item)"></view>
							<view style="width:40%;font-size: 38rpx;">{{item.studentName}}</view>
							<view class="attBtn" v-for="(i,index) in item.typeList"  @click="attBtnSkip(i,item.typeList)">
								<button  :class="[{'attBtnFontSlec':i.isShow},'attBtnFont']">{{i.type}}</button>						
							</view>								
						</view>
					
					<view v-if="attArr.length>index+1" class="attLine"></view>
				</view>				
			</view>
			<view class="leaveMgm1"  v-for="(item,num) in attArr1" :key="num">
				<view v-show="!isShowTitle">
					
						<view style="display: flex;flex-direction: row;">
							<view class="leaveCheck1" value="yes"></view>
							<view style="width:20%;font-size: 38rpx;">{{item.studentName}}</view>
							<view class="attBtn1" v-for="(i,num) in item.disArr" :key="num" @click="attBtnSkip(i,item.disArr)">
								<button  :class="[{'attBtnFontSlec':i.isShow},'attBtnFont1']">{{i.type}}</button>
							</view>								
						</view>
					
					<view v-if="attArr.length>num+1" class="attLine1"></view>
				</view>				
			</view>
		</view>
		<my-bottom :topName="topName" :classId="classId" :bottomArr="attendanceArr" :bottomName="bottomName"></my-bottom>
		
	</view>
</template>

<script>
	import topCom from '../component/topCom.vue'
	import bottomCom from '../component/bottom.vue'
	import headTitle from '../component/btnHeadeCom.vue'
	export default {
		name:'leveRegistration',
		data(){
			return{
				isShowTitle:true,
				userInfo:'',
				isShowList:false,
				userName:'',
				topName:'',
				titleHead:'考勤状况',
				bottomName:'moon',
				attArr:[
					{	id:202,
						student:'欧阳修',
						dormitoryNum:'202宿舍',
						typeList:[{
							type:"正常",
							isShow:false,
						},{
							type:"迟到",
							isShow:false,
						},{
							type:"请假",
							isShow:false,
						}],
						isShow:false,
						time:'请假时间',
					},
					{	id:203,
						student:'范增',
						dormitoryNum:'202宿舍',
						isShow:false,
						typeList:[{
							type:"正常",
							isShow:false,
						},{
							type:"迟到",
							isShow:false,
						},{
							type:"请假",
							isShow:false,
						}],
						time:'请假时间',
					},
					{	
						id:204,
						student:'杜甫',
						isShow:false,
						typeList:[{
							type:"正常",
							isShow:false,
						},{
							type:"迟到",
							isShow:false,
						},{
							type:"请假",
							isShow:false,
						}],
						dormitoryNum:'202宿舍',
						time:'请假时间',
					},
					{
						id:205,
						student:'李白',
						typeList:[{
							type:"正常",
							isShow:false,
						},{
							type:"迟到",
							isShow:false,
						},{
							type:"请假",
							isShow:false,
						}],
						isShow:false,
						dormitoryNum:'202宿舍',
						time:'请假时间',
					}
				],
				attendanceArr:[{					
                    name:'moring',
                    icon:'iconfont icon-yonghutongji',
                    text:"上午",
                    path: `/pages/classManagement/classManageAttendanceDetail`
                },
				{
				    name:'moon',
				    icon:'iconfont icon-yonghutongji',
				    text:"下午",
				    path: `/pages/classManagement/classManageAttendanceDetail1`
				},
				{
				    name:'night',
				    icon:'iconfont icon-yonghutongji',
				    text:"晚上",
				    path: `/pages/classManagement/classManageAttendanceDetail2`
				},],
				attArr1:[
					{
						student:'欧阳修',
						dormitoryNum:'202宿舍',
						time:'请假时间',
						disArr:[{
							type:"着装",
							isShow:false
						},{
							type:"睡觉",
							isShow:false},{
							type:"玩游戏",
							isShow:false},{
							type:"外出",
							isShow:false},{
							type:"抽烟",
							isShow:false}],
					},
					{
						student:'范增',
						dormitoryNum:'202宿舍',
						time:'请假时间',
						disArr:[{
							type:"着装",
							isShow:false
						},{
							type:"睡觉",
							isShow:false},{
							type:"玩游戏",
							isShow:false},{
							type:"外出",
							isShow:false},{
							type:"抽烟",
							isShow:false}],
					},
					{
						student:'杜甫',
						dormitoryNum:'202宿舍',
						time:'请假时间',
						disArr:[{
							type:"着装",
							isShow:false
						},{
							type:"睡觉",
							isShow:false},{
							type:"玩游戏",
							isShow:false},{
							type:"外出",
							isShow:false},{
							type:"抽烟",
							isShow:false}],
					},
					{
						student:'李白',
						dormitoryNum:'202宿舍',
						time:'请假时间',
						disArr:[{
							type:"着装",
							isShow:false
						},{
							type:"睡觉",
							isShow:false},{
							type:"玩游戏",
							isShow:false},{
							type:"外出",
							isShow:false},{
							type:"抽烟",
							isShow:false}],
					}
				],
				classId:'',
				timeSlot:2,
			}
		},
		components:{
			topCom,
			bottomCom,
			headTitle,
		},
		onShow(){
			var that = this
			uni.getStorage({
				key:"userInfo",
				success:(res)=>{
					that.userInfo  = res.data
					that.userName = res.data
				}
			})
		
		},
		onLoad(options) {
			this.topName = options.className
			this.classId = options.classId
		},
		mounted(){
			this.tecClassAttence()
			this.getAppClaStuAttenceListByCId()
		},
		methods:{
			
			getAppClaStuAttenceListByCId(){
				this.$api.teacher.getAppClaStuAttenceListByCId(this.classId,this.$date,this.timeSlot).then(res=>{
					this.attArr1 = res.data
					this.attArr1.forEach((item,index)=>{
						item.disArr=[{
							type:"着装",
							isShow:false
						},{
							type:"睡觉",
							isShow:false},{
							type:"玩游戏",
							isShow:false},{
							type:"外出",
							isShow:false},{
							type:"抽烟",
							isShow:false}]
							// 违纪类型 1:着装 2:睡觉 3:玩游戏 4:外出 5:抽烟
							if(item.dvType==1){
								item.disArr[0].isShow = true
							}else if(item.dvType == 2){
								item.disArr[1].isShow = true
							}else if(item.dvType == 3){
								item.disArr[2].isShow = true
							}else if(item.dvType == 4){
								item.disArr[3].isShow = true
							}else if(item.dvType == 5){
								item.disArr[4].isShow = true
							}
					})
					
				}).catch(e=>{
					
				})
			},
			tecClassAttence(){
				this.$api.teacher.tecClassAttence(this.$date,this.timeSlot,this.classId).then(res=>{
					this.attArr = res.data
					var typeList =	[{
						type:"正常",
						isShow:false,
					},{
						type:"迟到",
						isShow:false,
					},{
						type:"请假",
						isShow:false,
					}]
					this.attArr.forEach((item,index)=>{						
						item.typeList = [{
							type:"正常",
							isShow:false,
						},{
							type:"迟到",
							isShow:false,
						},{
							type:"请假",
							isShow:false,
						}]
						if(item.attenceStatus ==1){
							item.typeList[0].isShow = true
						}else if(item.attenceStatus ==2){
							item.typeList[1].isShow = true
						}else if(item.attenceStatus == 3){
							item.typeList[2].isShow = true
						}
					})
					
				}).catch(e=>{
						 
					 })
			},
			leaveIndexSkip(item){
				uni.navigateTo({
					// url: '/pages/leave/leaveManagement',
					// success: res => {},
					// fail: () => {},
					// complete: () => {}
				});
			},
			attBtnSkip(item,arr){
				for (let i in arr) {
					if(item.type!=arr[i].type){
						arr[i].isShow = false
					}
				}
				item.isShow = true	
				this.$forceUpdate()
			},
			checkFun(item){
				
			},
			attendanceTtileFun(){
				this.isShowTitle = !this.isShowTitle
			}
		}
	}
</script>

<style>
	.attBtn1{
		margin-right:4rpx;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		margin-top:-20rpx;		
	}
	.leaveNav{
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: row;
		font-size: 36upx;
		color:blue;
		width:100%;
		padding:50upx
	}
	.leaveBtn{
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/tubiao-01.png);
		background-size: 100%;
		width:190upx;
		height:60upx;
		color:white;
		font-size: 26upx;
		font-weight: 0;
	}
	.leaveLine{
		width:200upx;
		height:8upx;
		background:rgba(239, 220, 11, 1.0);
		opacity:0.78;
		position: relative;
		bottom: -10upx;
		left:-30upx;
	}
	.leaveMgm{
		color:#808080;
		font-size: 28upx;
		margin-top:50rpx;
	}
	.leaveMgm1{
		color:#808080;
		font-size: 28upx;
		margin-top:50rpx;
		margin-left:20rpx;
	}
	.leaveCheck{
		margin-left:60upx;
		margin-bottom: 30upx;
		
	}
	.attBtnFontSlec{
		border:solid #007AFF !important ;border-radius: 15upx;font-size: 30rpx;
		color:white;
		background-color: #007AFF;
	}
	.attBtnFont{
		border:solid #808080 0rpx !important;;font-size: 30rpx;
	}
	.attBtnFont1{
		border:solid #808080 0rpx !important;;font-size: 30rpx;
		padding-left: 18rpx !important;
		padding-right: 18rpx !important;
	}
	.attLine{
		width:720rpx;
		height:3upx;
		background:rgba(239, 237, 236, 1.0);
		opacity:0.78;
		position: relative;
		bottom: -18rpx;
		left:-1rpx;
	}
	.attLine1{
		width:720rpx;
		height:3upx;
		background:rgba(239, 237, 236, 1.0);
		opacity:0.78;
		position: relative;
		bottom: -18rpx;
		left:-20rpx;
	}
	.attBtn{
		width:60%;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		margin-top:-20upx;
		
	}
	.leaveBtn{
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/tubiao-01.png);
		width:190upx;
		height:60upx;
		color:white;
		font-size: 26upx;
		font-weight: 0;
	}
	.leaveLine{
		width:200upx;
		height:8upx;
		background:rgba(239, 220, 11, 1.0);
		opacity:0.78;
		position: relative;
		bottom: -10rpx;
		left:-30upx;
	}
	
	.leaveCheck1{
		margin-left:28rpx;
		margin-bottom: 30upx;		
	}
	.leaveCheck{
		margin-left:50rpx;
		margin-bottom: 30upx;		
	}
	.checkout{
		display: flex;
		justify-content: space-around;
		align-content: space-between;
	}
	.leaveTabLine{
		width:3upx;
		height:60upx;
		background:#8F8F94;
		opacity:0.78;
		position: relative;
		top: 0upx;
		left:150upx;
	}
	.indexContent{
		height: unset !important;
	}
</style>
